<?php

declare(strict_types=1);

namespace App\Request\Admin;

use Hyperf\Validation\Request\FormRequest;

class AdminUserRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function rules()
    {
        $id = $this->input('id');

        return [
            'username'           => 'bail|required|unique:admin_users,username,'  . $id,
            'password'           => 'required'
        ];
    }

    public function messages(): array
    {
        return [
            'username.required'     =>  '管理员名称必填',
            'username.unique'     =>  '管理员名称已存在',

            'password.required'       =>  '密码必填'
        ];
    }
}
